package ltd.dujiabao.dualwrite.datasource;

import lombok.Getter;

import java.sql.SQLException;
import java.sql.Savepoint;

/**
 * @author Bowie Du
 * @date 2025/11/1 10:15
 */
@Getter
public class DualWriteSavepoint implements Savepoint {
    private final Savepoint prioritySavePoint;
    private final Savepoint secondarySavePoint;

    public DualWriteSavepoint(Savepoint prioritySavePoint, Savepoint secondarySavePoint) {
        this.prioritySavePoint = prioritySavePoint;
        this.secondarySavePoint = secondarySavePoint;
    }


    @Override
    public int getSavepointId() throws SQLException {
        return prioritySavePoint.getSavepointId();
    }

    @Override
    public String getSavepointName() throws SQLException {
        return prioritySavePoint.getSavepointName();
    }
}
